package cn.edu.zafu.bigdata.yt.yichangchuli;

public class ArithmeticExceptionDemo_yt {

    public static int divide(int a, int b) {
        if (b == 0) {
            throw new ArithmeticException("Division by zero is banned.");
        }
        return a / b;
    }

    public static void main(String[] args) {
        try {
            int result1 = divide(10, 5);
            System.out.println("10 / 5 = " + result1);

            int result2 = divide(10, 0);
            System.out.println("10 / 0 = " + result2);  
        } catch (ArithmeticException e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}


